Allow stdin on posix gbser filename.
authorrobertl <robertl>
Tue, 3 Jul 2007 04:03:37 +0000 (04:03 +0000)
committerrobertl <robertl>
Tue, 3 Jul 2007 04:03:37 +0000 (04:03 +0000)
gbser_posix.c

index 15bf4d007f33ee2b4a8d5d085ca0eca00f983467..689386ffebf6f0db4a2a7b8baa53ed2356e49233 100644 (file)
@@ -117,10 +117,14 @@ void *gbser_init(const char *port_name) {
        h->magic = MYMAGIC;
        h->vmin = h->vtime = 0;
 
-    if (h->fd = open(port_name, O_RDWR | O_NOCTTY), h->fd == -1) {
+       if (0 == strcmp(port_name, "-") {
+               h->fd = 0;
+               return h;
+       }
+        else if (h->fd = open(port_name, O_RDWR | O_NOCTTY), h->fd == -1) {
                gbser__db(1, "Failed to open port (%s)\n", strerror(errno));    
-        goto failed;
-    }
+               goto failed;
+       }
 
        if (!isatty(h->fd)) { 
                gbser__db(1, "%s is not a TTY\n");